package com.example.demo.controller;

import com.example.demo.model.Order;
import com.example.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

@RestController
public class OrderController {
    @Autowired
    OrderService orderService;

    @RequestMapping("/add")
    public String add(String createTime) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        orderService.add(sdf.parse(createTime));
        return "success";
    }

    @RequestMapping("/select")
    public List<Order> select(Order order) {
        return orderService.select(order);
    }

    @RequestMapping("/selectByTime")
    public List<Order> selectByTime(String start,String end) {
        return orderService.selectByTime(start,end);
    }

    @RequestMapping("/addNotSharding")
    public String addNotSharding() {
        orderService.addNotSharding();
        return "success";
    }
}
